home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 19 / CU Amiga Magazine's Super CD-ROM 19 (1998)(EMAP Images)(GB)[!][issue 1998-02].iso / CUCD / Programming / LEDA / source / src / window / _window.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-16  |  16.5 KB  |  755 lines

  1. /*******************************************************************************
  2. +
  3. +  LEDA  3.1c
  4. +
  5. +
  6. +  _window.c
  7. +
  8. +
  9. +  Copyright (c) 1994  by  Max-Planck-Institut fuer Informatik
  10. +  Im Stadtwald, 6600 Saarbruecken, FRG     
  11. +  All rights reserved.
  12. *******************************************************************************/
  13.  
  14.  
  15.  
  16. #include <LEDA/window.h>
  17. #include <math.h>
  18.  
  19.  
  20.  
  21.  
  22. //------------------------------------------------------------------------------
  23. // WINDOW BASICS
  24. //------------------------------------------------------------------------------
  25.  
  26.  
  27. static void window_error_handler(int i, const char* s)
  28. { if (i==0) return;
  29.   panel P;
  30.   P.text_item(string("ERROR(%d): %s",i,s));
  31.   P.button("exit");
  32.   P.button("dump core");
  33.   if (P.open() == 0)
  34.      exit(0);
  35.   else 
  36.      abort();
  37.  }
  38.  
  39. window::window(float width,float height,float xpos,float ypos,const char* label)
  40. : LEDA_WINDOW(width,height,xpos,ypos, label)
  41. { set_error_handler(window_error_handler); }
  42.  
  43. window::window(float width, float height, const char* label)
  44. : LEDA_WINDOW(width,height,label)
  45. { set_error_handler(window_error_handler); }
  46.  
  47. window::window(const char* label) : LEDA_WINDOW(label)
  48. { set_error_handler(window_error_handler); }
  49.  
  50. window::window(int) // do not open
  51. { set_error_handler(window_error_handler); }
  52.  
  53.  
  54.  
  55. //------------------------------------------------------------------------------
  56. // WINDOW OUTPUT
  57. //------------------------------------------------------------------------------
  58.  
  59.  
  60. // pixels
  61.  
  62. void window::draw_pix(double x, double y, color c ) 
  63. { LEDA_WINDOW::draw_pix(x,y,c); }
  64.  
  65. void window::draw_pix(const point& p, color c ) 
  66. { draw_pix(p.xcoord(),p.ycoord(),c); }
  67.  
  68. void window::draw_text(double x, double y, string s, color c)
  69. { LEDA_WINDOW::draw_text(x,y,s,c); }
  70.  
  71. void window::draw_text(const point& p, string s, color c)
  72. { draw_text(p.xcoord(),p.ycoord(),s,c); }
  73.  
  74. void window::draw_ctext(double x, double y, string s, color c)
  75. { LEDA_WINDOW::draw_ctext(x,y,s,c); }
  76.  
  77. void window::draw_ctext(const point& p, string s, color c)
  78. { draw_ctext(p.xcoord(),p.ycoord(),s,c); }
  79.  
  80. // points
  81.  
  82. void window::draw_point(double x0,double y0,color c)
  83. { LEDA_WINDOW::draw_point(x0,y0,c); }
  84.  
  85. void window::draw_point(const point& p,color c)
  86. { draw_point(p.xcoord(),p.ycoord(),c); }
  87.  
  88.  
  89. // segments
  90.  
  91. void window::draw_segment(double x1, double y1, double x2, double y2, color c )
  92. { LEDA_WINDOW::draw_segment(x1,y1,x2,y2,c); }
  93.  
  94. void window::draw_segment(const point& p, const point& q, color c )
  95. { window::draw_segment(p.xcoord(),p.ycoord(),q.xcoord(),q.ycoord(),c); }
  96.  
  97. void window::draw_segment(const segment& s, color c )
  98. { draw_segment(s.start(),s.end(),c); }
  99.  
  100.  
  101. // lines
  102.  
  103.  
  104. void window::draw_line(const line& l, color c )
  105. {
  106.   double a,x0,x1,y0,y1;
  107.  
  108.   if (l.vertical()) 
  109.   { draw_vline(l.x_proj(0),c);
  110.     return;
  111.    }
  112.  
  113.   a = l.slope();
  114.  
  115.   if (fabs(a) < 1)
  116.   { x0 = xmin();
  117.     x1 = xmax();
  118.     y0 = l.y_proj(x0);
  119.     y1 = l.y_proj(x1);
  120.    }
  121.   else
  122.   { y0 = ymin();
  123.     y1 = ymax();
  124.     x0 = l.x_proj(y0);
  125.     x1 = l.x_proj(y1);
  126.    }
  127.  
  128.   LEDA_WINDOW::draw_segment(x0,y0,x1,y1,c);
  129.  
  130. }
  131.  
  132.  
  133. void window::draw_line(const segment& s, color c )
  134. { draw_line(line(s),c); }
  135.  
  136. void window::draw_line(const point& p, const point& q, color c) 
  137. { draw_line(line(p,q),c); }
  138.  
  139. void window::draw_line(double x1, double y1, double x2, double y2, color c )
  140. { draw_line(segment(x1,y1,x2,y2),c); }
  141.  
  142.  
  143. void window::draw_hline(double y, color c )
  144. { LEDA_WINDOW::draw_segment(xmin(),y,xmax(),y,c); }
  145.  
  146. void window::draw_vline(double x, color c )
  147. { LEDA_WINDOW::draw_segment(x,ymin(),x,ymax(),c); }
  148.  
  149.  
  150.  
  151.  
  152. // nodes
  153.  
  154. void window::draw_node(double x0,double y0,color c) 
  155. { LEDA_WINDOW::draw_node(x0,y0,c); }
  156.  
  157. void window::draw_node(const point& p, color c)
  158. { window::draw_node(p.xcoord(),p.ycoord(),c); }
  159.  
  160. void window::draw_filled_node(double x0,double y0,color c)
  161. { LEDA_WINDOW::draw_filled_node(x0,y0,c); }
  162.  
  163. void window::draw_filled_node(const point& p, color c)
  164. { window::draw_filled_node(p.xcoord(),p.ycoord(),c); }
  165.  
  166. void window::draw_text_node(double x,double y,string s,color c)
  167. { LEDA_WINDOW::draw_text_node(x,y,~s,c); }
  168.  
  169. void window::draw_text_node(const point& p ,string s,color c)
  170. { window::draw_text_node(p.xcoord(),p.ycoord(),~s,c); }
  171.  
  172. void window::draw_int_node(double x,double y,int i,color c)
  173. { LEDA_WINDOW::draw_int_node(x,y,i,c); }
  174.  
  175. void window::draw_int_node(const point& p ,int i,color c)
  176. { window::draw_int_node(p.xcoord(),p.ycoord(),i,c); }
  177.  
  178.  
  179. //circles
  180.  
  181. void window::draw_circle(double x,double y,double r,color c)
  182. { LEDA_WINDOW::draw_circle(x,y,r,c); }
  183.  
  184. void window::draw_circle(const point& p,double r,color c)
  185. { LEDA_WINDOW::draw_circle(p.xcoord(),p.ycoord(),r,c); }
  186.  
  187. void window::draw_circle(const circle& C,color c)
  188. { point p = C.center();
  189.   double r = C.radius();
  190.   LEDA_WINDOW::draw_circle(p.xcoord(),p.ycoord(),r,c); 
  191.  }
  192.  
  193.  
  194. // discs
  195.  
  196. void window::draw_disc(double x,double y,double r,color c)
  197. { LEDA_WINDOW::draw_filled_circle(x,y,r,c); }
  198.  
  199. void window::draw_disc(const point& p,double r,color c)
  200. { window::draw_disc(p.xcoord(),p.ycoord(),r,c); }
  201.  
  202.  
  203. void window::draw_disc(const circle& C,color c)
  204. { draw_disc(C.center(),C.radius(),c); }
  205.  
  206.  
  207.  
  208. //ellipses
  209.  
  210. void window::draw_ellipse(double x,double y,double r1,double r2,color c)
  211. { LEDA_WINDOW::draw_ellipse(x,y,r1,r2,c); }
  212.  
  213. void window::draw_ellipse(const point& p, double r1, double r2, color c)
  214. { LEDA_WINDOW::draw_ellipse(p.xcoord(),p.ycoord(),r1,r2,c); }
  215.  
  216. void window::draw_filled_ellipse(double x,double y,double r1,double r2,color c)
  217. { LEDA_WINDOW::draw_filled_ellipse(x,y,r1,r2,c); }
  218.  
  219. void window::draw_filled_ellipse(const point& p, double r1, double r2, color c)
  220. { LEDA_WINDOW::draw_filled_ellipse(p.xcoord(),p.ycoord(),r1,r2,c); }
  221.  
  222.  
  223.  
  224. // arcs
  225.  
  226. void window::draw_arc(const segment& s, double r, color col)
  227. { double d   = s.length()/(2*fabs(r));
  228.   if (d > 1) return;
  229.   double acd = acos(d);
  230.   if (r < 0) 
  231.     { point   m  = s.start().translate(s.angle()-acd,-r);
  232.       segment x(m,s.end());
  233.       LEDA_WINDOW::draw_arc(m.xcoord(),m.ycoord(),-r,-r,x.angle(),M_PI-2*acd,col);
  234.      }
  235.   else 
  236.     { point   m  = s.start().translate(s.angle()+acd,r);
  237.       segment x(m,s.end());
  238.       LEDA_WINDOW::draw_arc(m.xcoord(),m.ycoord(),r,r,x.angle(),2*acd-M_PI,col);
  239.      }
  240.  }
  241.  
  242. void window::draw_arc(double x0,double y0,double x1,double y1,double r,color c)
  243. { draw_arc(segment(x0,y0,x1,y1),r,c); }
  244.  
  245. void window::draw_arc(const point& p, const point& q, double r, color c)
  246. { draw_arc(segment(p,q),r,c); }
  247.  
  248.  
  249.  
  250. void window::draw_arc_arrow(const segment& s, double r, color col)
  251. { double d   = s.length()/(2*r);
  252.   if (d > 1) return;
  253.   point p = draw_arrow_head(s.end(), s.angle() + M_PI/2 - acos(d), col);
  254.   draw_arc(s.start(),p,r,col);
  255.  }
  256.  
  257. void window::draw_arc_arrow(double x0,double y0,double x1,double y1,double r,color c)
  258. { draw_arc_arrow(segment(x0,y0,x1,y1),r,c); }
  259.  
  260. void window::draw_arc_arrow(const point& p, const point& q, double r, color c)
  261. { draw_arc_arrow(segment(p,q),r,c); }
  262.  
  263.  
  264. // polygons
  265.  
  266. void window::draw_polygon(const list<point>& lp, color c)
  267. { int n = lp.length();
  268.   double* X = new double[n];
  269.   double* Y = new double[n];
  270.   n = 0;
  271.   point p;
  272.   forall(p,lp) 
  273.   { X[n] = p.xcoord();
  274.     Y[n] = p.ycoord();
  275.     n++;
  276.    }
  277.   LEDA_WINDOW::draw_polygon(n,X,Y,c);
  278.   delete X;
  279.   delete Y;
  280. }
  281.  
  282. void window::draw_filled_polygon(const list<point>& lp, color c)
  283. { int n = lp.length();
  284.   double* X = new double[n];
  285.   double* Y = new double[n];
  286.   n = 0;
  287.   point p;
  288.   forall(p,lp) 
  289.   { X[n] = p.xcoord();
  290.     Y[n] = p.ycoord();
  291.     n++;
  292.    }
  293.   LEDA_WINDOW::draw_filled_polygon(n,X,Y,c);
  294.   delete X;
  295.   delete Y;
  296. }
  297.  
  298. void window::draw_polygon(const polygon& P, color c )
  299. { draw_polygon(P.vertices(),c); }
  300.  
  301. void window::draw_filled_polygon(const polygon& P,color c )
  302. { draw_filled_polygon(P.vertices(),c); }
  303.  
  304.  
  305.  
  306.  
  307. void window::draw_rectangle(double a, double  b, double c, double d, color col)
  308. { LEDA_WINDOW::draw_rectangle(a,b,c,d,col); }
  309.  
  310. void window::draw_filled_rectangle(double a, double  b, double c, double d, color col)
  311. { LEDA_WINDOW::draw_filled_rectangle(a,b,c,d,col); }
  312.  
  313.  
  314. // functions
  315.  
  316. void window::plot_xy(double x0, double x1, draw_func_ptr f, color c)
  317. { LEDA_WINDOW::plot_xy(x0,x1,f,c); }
  318.  
  319. void window::plot_yx(double y0, double y1, draw_func_ptr f, color c)
  320. { LEDA_WINDOW::plot_yx(y0,y1,f,c); }
  321.  
  322.  
  323.  
  324. // arrows
  325.  
  326. point window::draw_arrow_head(const point& q, double a, color c)
  327. { double X[4];
  328.   double Y[4];
  329.   
  330.   double alpha = a-M_PI; 
  331.  
  332.   double d = 2*((get_line_width()+2)/3.0)/scale();
  333.  
  334.   point l = q.translate(alpha+M_PI/6, 7*d);
  335.   point m = q.translate(alpha,        4*d);
  336.   point r = q.translate(alpha-M_PI/6, 7*d);
  337.  
  338.  
  339.   X[0] = q.xcoord();
  340.   Y[0] = q.ycoord();
  341.   X[1] = l.xcoord();
  342.   Y[1] = l.ycoord();
  343.   X[2] = m.xcoord();
  344.   Y[2] = m.ycoord();
  345.   X[3] = r.xcoord();
  346.   Y[3] = r.ycoord();
  347.  
  348.   LEDA_WINDOW::draw_filled_polygon(4,X,Y,c);
  349.   return m;
  350. }
  351.  
  352.  
  353. void window::draw_arrow(const segment& s, color c)
  354. { point q = draw_arrow_head(s.end(),s.angle(),c);
  355.   draw_segment(s.start(),q,c);
  356. }
  357.  
  358. void window::draw_arrow(const point& p, const point& q, color c)
  359. { draw_arrow(segment(p,q),c); }
  360.  
  361. void window::draw_arrow(double x0, double y0, double x1, double y1, color c)
  362. { draw_arrow(segment(x0,y0,x1,y1),c); }
  363.  
  364.  
  365.  
  366.  
  367.  
  368. // edges
  369.  
  370. void window::draw_edge(double x0, double y0, double x1, double y1, color c)
  371. { LEDA_WINDOW::draw_edge(x0,y0,x1,y1,c); }
  372.  
  373. void window::draw_edge(const point& p, const point& q, color c)
  374. { draw_edge(p.xcoord(),p.ycoord(),q.xcoord(),q.ycoord(),c); }
  375.  
  376. void window::draw_edge(const segment& s, color c)
  377. { draw_edge(s.start(),s.end(),c); }
  378.  
  379.  
  380. void window::draw_arc_edge(double x0, double y0, double x1, double y1, color c)
  381. { draw_arc_edge(segment(x0,y0,x1,y1),c); }
  382.  
  383. void window::draw_arc_edge(const point& p, const point& q, double r, color c)
  384. { draw_arc_edge(segment(p,q),r,c); }
  385.  
  386. void window::draw_arc_edge(const segment& s, double r, color c)
  387. { double R = get_node_width()/scale();
  388.   double d = s.length()/(2*r);
  389.   if (d > 1) return;
  390.   point p = s.start().translate(s.angle() - M_PI/2 + acos(d), R);
  391.   point q = s.end().translate(s.angle() + M_PI/2 - acos(d),  -R);
  392.   draw_arc(p,q,r,c);
  393.  }
  394.  
  395.  
  396. void window::draw_edge_arrow(double x0,double y0,double x1,double y1,color c)
  397. { draw_edge_arrow(segment(x0,y0,x1,y1),c); }
  398.  
  399. void window::draw_edge_arrow(const point& p, const point& q, color c)
  400. { draw_edge_arrow(segment(p,q),c); }
  401.  
  402. void window::draw_edge_arrow(const segment& s, color c)
  403. { double  alpha = s.angle();
  404.   point p = s.start().translate(alpha,get_node_width()/scaling);
  405.   point q = s.end().translate(alpha,-get_node_width()/scaling);
  406.   draw_arrow(p,q,c);
  407. }
  408.  
  409.  
  410.  
  411. void window::draw_arc_edge_arrow(double x,double y,double x1,double y1,color c)
  412. { draw_arc_edge_arrow(segment(x,y,x1,y1),c); }
  413.  
  414. void window::draw_arc_edge_arrow(const point& p, const point& q, double r, color c)
  415. { draw_arc_edge_arrow(segment(p,q),r,c); }
  416.  
  417. void window::draw_arc_edge_arrow(const segment& s, double r, color c)
  418. { double R = get_node_width()/scale();
  419.   double d = s.length()/(2*r);
  420.   if (d > 1) return;
  421.   point p = s.start().translate(s.angle() - M_PI/2 + acos(d), R);
  422.   point q = s.end().translate(s.angle() + M_PI/2 - acos(d),  -R);
  423.   draw_arc_arrow(p,q,r,c);
  424.  }
  425.  
  426.  
  427. //------------------------------------------------------------------------------
  428. // WINDOW INPUT
  429. //------------------------------------------------------------------------------
  430.  
  431.  
  432. int window::get_button() 
  433. { double x,y;
  434.   return LEDA_WINDOW::get_button(x,y); 
  435.  }
  436.  
  437. int window::get_button(double& x, double& y) 
  438. { return LEDA_WINDOW::get_button(x,y); }
  439.  
  440. int  window::get_button(point& q)
  441. { double x,y;
  442.   int key = LEDA_WINDOW::get_button(x,y);
  443.   q = point(x,y);
  444.   return key;
  445.  }
  446.  
  447.  
  448. int window::read_mouse()
  449. { double d;
  450.   return LEDA_WINDOW::read_mouse(0,0.0,0.0,d,d);
  451.  }
  452.  
  453. int  window::read_mouse(double& x, double& y)
  454. { return LEDA_WINDOW::read_mouse(0,0.0,0.0,x,y); }
  455.  
  456. int  window::read_mouse(point& q)
  457. { double x,y;
  458.   int key = LEDA_WINDOW::read_mouse(0,0.0,0.0,x,y);
  459.   q = point(x,y);
  460.   return key;
  461.  }
  462.  
  463.  
  464. int  window::read_mouse_seg(double x0, double y0, double& x, double& y)
  465. { return LEDA_WINDOW::read_mouse(1,x0,y0,x,y); }
  466.  
  467. int  window::read_mouse_seg(const point& p, point& q)
  468. { double X,Y;
  469.   int key = LEDA_WINDOW::read_mouse(1,p.xcoord(),p.ycoord(),X,Y);
  470.   q = point(X,Y);
  471.   return key;
  472. }
  473.  
  474.  
  475. int  window::read_mouse_rect(double x0, double y0, double& x, double& y)
  476. { return LEDA_WINDOW::read_mouse(2,x0,y0,x,y); }
  477.  
  478.  
  479. int  window::read_mouse_rect(const point& p, point& q)
  480. { double X,Y;
  481.   int key = LEDA_WINDOW::read_mouse(2,p.xcoord(),p.ycoord(),X,Y);
  482.   q = point(X,Y);
  483.   return key;
  484. }
  485.  
  486.  
  487. int  window::read_mouse_circle(double x0, double y0, double& x, double& y)
  488. { return LEDA_WINDOW::read_mouse(3,x0,y0,x,y); }
  489.  
  490.  
  491. int  window::read_mouse_circle(const point& p, point& q)
  492. { double X,Y;
  493.   int key = LEDA_WINDOW::read_mouse(3,p.xcoord(),p.ycoord(),X,Y);
  494.   q = point(X,Y);
  495.   return key;
  496. }
  497.  
  498.  
  499.  
  500. int window::read_mouse_action(mouse_action_func_ptr f, double& x, double& y)
  501. { return LEDA_WINDOW::read_mouse_action(f,0.0,0.0,x,y); }
  502.  
  503.  
  504. int window::read_mouse_action(mouse_action_func_ptr f, point& q)
  505. { double X,Y;
  506.   int key = LEDA_WINDOW::read_mouse_action(f,0.0,0.0,X,Y);
  507.   q = point(X,Y);
  508.   return key;
  509. }
  510.  
  511.  
  512.  
  513. window& window::read(point& p)
  514. { double x,y;
  515.   state = 1;
  516.   int k;
  517.   while ((k = read_mouse(x,y)) != 1) 
  518.    if (k == 3) 
  519.     { state = 0;
  520.       return *this;
  521.      }
  522.   p = point(x,y);
  523.   return *this;
  524.  }
  525.  
  526.  
  527. window& window::read(segment& s)
  528. { double x,y;
  529.   point p;
  530.   int key = 0;
  531.   state = 1;
  532.  
  533.   if (!read(p).state) 
  534.    return *this;
  535.  
  536.   while ((key=read_mouse_seg(p.xcoord(),p.ycoord(),x,y)) != 1)
  537.   { if (key== 3)  
  538.      { state = 0;
  539.        break; 
  540.       }
  541.  
  542.     if (key==-1)
  543.       if (!read(p).state) break;
  544.    }
  545.  
  546.    if (state) s = segment(p.xcoord(),p.ycoord(),x,y);
  547.  
  548.   return *this;
  549. }
  550.  
  551. window& window::read(line& l)
  552. { segment s;
  553.   state = 1;
  554.   read(s);
  555.   if (state) l = line(s);
  556.   return *this;
  557.  }
  558.  
  559.  
  560. window& window::read(circle& c)
  561. { double x,y;
  562.   point p;
  563.   int key = 0;
  564.   state = 1;
  565.  
  566.   if (!read(p).state) 
  567.    return *this;
  568.  
  569.   drawing_mode save = set_mode(xor_mode);
  570.   draw(p);
  571.  
  572.   while ((key=read_mouse_circle(p.xcoord(),p.ycoord(),x,y)) != 1)
  573.   { if (key== 3)  
  574.      { state = 0;
  575.        break; 
  576.       }
  577.  
  578.     if (key==-1)
  579.     { draw(p);
  580.       if (!read(p).state) break;
  581.       draw(p);
  582.      }
  583.    }
  584.    if (state) 
  585.    { double dx = x-p.xcoord();
  586.      double dy = y-p.ycoord();
  587.      c = circle(p,hypot(dx,dy));
  588.      draw(p);
  589.     }
  590.  
  591.   set_mode(save);
  592.   return *this;
  593. }
  594.  
  595. window& window::read(polygon& P)
  596. { double x,y;
  597.   int key = 0;
  598.   state = 1;
  599.   point first,last,p;
  600.   list<point> pl;
  601.  
  602.   if (!read(first).state) return *this;
  603.  
  604.   pl.append(first);
  605.  
  606.   p = first;
  607.  
  608.   drawing_mode save = set_mode(xor_mode);
  609.  
  610.   while ((key = read_mouse_seg(p.xcoord(),p.ycoord(),x,y)) !=2)
  611.   { 
  612.     if (key==3) break;
  613.  
  614.     if (key==-1 && pl.length() > 1 ) 
  615.     { point l = pl.Pop();
  616.       draw_segment(pl.tail(),l);
  617.       p = pl.tail();
  618.      }
  619.  
  620.     if (key==1)
  621.     { point q(x,y);
  622.       draw_segment(p,q);
  623.       pl.append(q);
  624.       p = q;
  625.      }
  626.   }
  627.  
  628.  
  629.   draw_segment(first,p);
  630.  
  631.   list_item it;
  632.   forall_items(it,pl) draw_segment(pl[it],pl[pl.cyclic_succ(it)]);
  633.  
  634.  
  635.   P = polygon(pl);
  636.  
  637.   if (key==3)
  638.   { state = 0;
  639.     Clear(P);
  640.     Init(P);
  641.    }
  642.  
  643.   set_mode(save);
  644.  
  645.   return *this;
  646.  
  647. }
  648.  
  649.  
  650. window& window::operator>>(point& p)    
  651. { set_frame_label(">> POINT");
  652.   read(p); 
  653.   reset_frame_label();
  654.   return *this; 
  655.  }
  656.  
  657. window& window::operator>>(segment& s)  
  658. { set_frame_label(">> SEGMENT");
  659.   read(s); 
  660.   reset_frame_label();
  661.   return *this; 
  662.  }
  663.  
  664. window& window::operator>>(line& l)     
  665. { set_frame_label(">> LINE");
  666.   read(l); 
  667.   reset_frame_label();
  668.   return *this; 
  669.  }
  670.  
  671. window& window::operator>>(circle& C)   
  672. { set_frame_label(">> CIRCLE");
  673.   read(C); 
  674.   reset_frame_label();
  675.   return *this; 
  676.  }
  677.  
  678. window& window::operator>>(polygon& P)  
  679. { set_frame_label(">> POLYGON");
  680.   read(P); 
  681.   reset_frame_label();
  682.   return *this; 
  683.  }
  684.  
  685.  
  686.  
  687.  
  688. int window::confirm(string s)
  689. { panel p;
  690.   p.text_item(s);
  691.   p.button("YES");
  692.   p.button("NO");
  693.   return 1 - p.open();
  694. }
  695.  
  696.  
  697. void window::acknowledge(string s)
  698. { panel p;
  699.   p.text_item(s);
  700.   p.button("CONTINUE");
  701.   p.open();
  702. }
  703.  
  704. void window::notice(string s)
  705. { panel p;
  706.   p.text_item(s);
  707.   p.button("CONTINUE");
  708.   p.open();
  709. }
  710.  
  711.  
  712. int  window::read_panel(string header, int n, string* L)
  713. { panel P("LEDA PANEL");
  714.   P.text_item(header);
  715.   for(int i = 0; i < n; i++) P.button(L[i]);
  716.   return P.open();
  717.  }
  718.  
  719.  
  720. int  window::read_vpanel(string header, int n, string* L)
  721. { panel P("LEDA PANEL");
  722.   P.text_item(header);
  723.   for(int i = 0; i < n; i++) 
  724.   { P.button(L[i]);
  725.     P.new_button_line();
  726.    }
  727.   return P.open();
  728.  }
  729.  
  730.  
  731. string  window::read_string(string prompt)
  732. { panel P("STRING INPUT PANEL");
  733.   string s;
  734.   P.string_item(prompt,s);
  735.   P.open();
  736.   return s;
  737.  }
  738.  
  739. int  window::read_int(string prompt)
  740. { panel P("INT INPUT PANEL");
  741.   int i;
  742.   P.int_item(prompt,i);
  743.   P.open();
  744.   return i;
  745. }
  746.  
  747. double  window::read_real(string prompt)
  748. { panel P("DOUBLE INPUT PANEL");
  749.   double x;
  750.   P.real_item(prompt,x);
  751.   P.open();
  752.   return x;
  753.  }
  754.